
enum ko_type {
    KO_TYPE_FILE = 0,
    KO_TYPE_CONS = 1,
    KO_TYPE_PIPE = 2
};

enum ko_mode {
    KO_MODE_R = 0,
    KO_MODE_W = 1,
    KO_MODE_RW = 2
};
struct ko;
typedef int (*rwfn) (struct ko* o, void* kptr, unsigned int sz);

struct ko {
    char name[MAX_NAMESZ];
    void * ctx;
    enum ko_type type;
    enum ko_mode mode;
    int id;
    // uint32 rptr;
    // uint32 wptr;
    uint32 refs;
    uint32 magic;
    struct sleeplk lk;
    rwfn read;
    rwfn write;
    int(*freeinside)(void *);
};
